<?php
include_once('../../app/connection.php');

if(isset($_POST['action']))
{
    $action = $_POST['action'];
    if($action == "get_info" && $_POST['mssv'] != "")
    {
        $mssv=""; $array="";
        $mssv = $_POST['mssv'];
            
        $sql = "SELECT * FROM sinhvien WHERE MSSV LIKE'".$mssv."%'";
        $result = mysql_query($sql);
        
        if(mysql_num_rows($result)!=0)
        {            
            $string = "";
            while($row = mysql_fetch_assoc($result))
            {
                $string .=  $row['MSSV'].',';               
            }
            $count = count($array);
            echo $string;
        }
    }
    
    if($action == "Chỉnh sửa")
    {
        $mssv="";
        $mssv = $_POST['mssv'];
        
        $sql = "UPDATE sinhvien SET HOTEN='".$_POST['hoten']."', GIOITINH='".$_POST['gioitinh']."', 
            NGAYSINH='".$_POST['ngaysinh']."', MAKHOA='".$_POST['khoa']."', KHOAHOC='".$_POST['khoahoc']."' 
            WHERE MSSV='$mssv'";
        $result = mysql_query($sql) or die("Co loi xay ra");
        
        header('Location: ../?page=quanlysv&function=thongtin');
    }  
}
?>